#选择排序
"""def selection_sort():
    data = [1,56,6,5,4,89,2]
    length = len(data)
    for i in range(length-1):
        small = data[i]
        for j in range(i+1,length):
            if data[j]<small:
                idx = j
                data[idx],data[i] = data[i],data[idx]
    return data
result = selection_sort()
print(result)
"""
def choose_sort(num_list):
    length=len(num_list)
    for i in range(length-1):
        min=num_list[i]
        for j in range(i,length):
            if num_list[j]<min:
                index=j
                num_list[index],num_list[i]=num_list[i],num_list[index]
    return num_list
print(choose_sort([1,8,2,1,7]))